﻿@model PrjctMngmt.Models.Project

<script type="text/javascript">
    $(function () {
        $("#category").dialog({
            autoOpen: false, width: 400, modal: true,
            buttons: {
                "Save": function () {
                    $.post("/ProjectCategory/Create",
                        $("#ProjectCategoryForm").serialize(),
                        function () {
                            $("#category").dialog("close");
                            window.location.reload();
                        });
                },
                Cancel: function () { $(this).dialog("close"); }
            }
        });
        $(".addCategory").click(function () {
            $("#category").html("")
                .dialog("option", "title", "Create category")
                .load("/ProjectCategory/Create", function () { $("#category").dialog("open"); });
        });
    });
</script>

<script type="text/javascript">
    $(function () {
        $("#client").dialog({
            autoOpen: false, width: 400, modal: true,
            buttons: {
                "Save": function () {
                    $.post("/Client/CreateDialog",
                        $("#ClientForm").serialize(),
                        function () {
                            $("#client").dialog("close");
                            window.location.reload();
                        });
                },
                Cancel: function () { $(this).dialog("close"); }
            }
        });
        $(".addClient").click(function () {
            $("#client").html("")
                .dialog("option", "title", "Create client")
                .load("/Client/CreateDialog", function () { $("#client").dialog("open"); });
        });
    });
</script>

<script type="text/javascript">
    $(function () {
        $(".datetimepicker").datetimepicker({
            timeFormat: 'hh:mm:ss',
            dateFormat: 'dd-mm-yy'
        });
    });
</script>

<script type="text/javascript" >
    $(document).ready(function () {
        $("#editor").markItUp(mySettings);
    });
</script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Project</legend>

        <p>* indicates a required field.</p>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name) *
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            Start date
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.StartDate, new { @class = "datetimepicker" })
            @Html.ValidationMessageFor(model => model.StartDate)
        </div>

        <div class="editor-label">
            Due date
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.DueDate, new { @class = "datetimepicker" })
            @Html.ValidationMessageFor(model => model.DueDate)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Status)
        </div>
        <div class="editor-field">
            @Html.DropDownList("Status", (IEnumerable<SelectListItem>)ViewData["Status"], "")
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Description, new { @cols = 50, @rows = 10, @id = "editor" })
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-label">
            Client
        </div>
        <div class="editor-field">
            @Html.DropDownList("ClientID", (IEnumerable<SelectListItem>) ViewData["Clients"], "")
            <img alt="Create client" class="addClient ButtonLink Top" src="../../Content/themes/base/images/plus-sign_small.png" />
        </div>

        <div class="editor-label">
            Category
        </div>
        <div class="editor-field">
            @Html.DropDownList("ProjectCategoryID", (IEnumerable<SelectListItem>) ViewData["ProjectCategories"], "")
            <img alt="Create category" class="addCategory ButtonLink Top" src="../../Content/themes/base/images/plus-sign_small.png" />
        </div>

        <p>
            <input type="submit" value="Submit" />
        </p>

        <div id="category"></div>
        <div id="client"></div>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>